<%--
  Created by IntelliJ IDEA.
  User: a'su's
  Date: 2020/9/21
  Time: 20:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>系统消息</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../../taofang/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="../../../taofang/css/TenantCentre.css">
    <link rel="stylesheet" href="../../../taofang/css/home.css">
</head>
<body>
<script src="../../../taofang/plugins/jquery-3.4.1.js"></script>
<script src="../../../taofang/plugins/bootstrap-3.3.7-dist/js/bootstrap.js"></script>

<%@include file="top.jsp"%>

<div class="col-md-9 zy3">
    <table class="table table-hover">
        <thead>
        <thead>
        <tr>
            <th>回复时间</th>
            <th>消息内容</th>
            <th>回复人(用户名)</th>
            <th>删除</th>
        </tr>
        </thead>
        <tbody id="tb">


        <c:forEach items="${message}" var="m">

            <tr>
                <td><fmt:formatDate value="${m.responseTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                <td><button type="button" class="btn btn-primary"
                            data-container="body" data-toggle="popover" data-placement="top"
                            data-content="${m.messageContent}">
                    点击查看
                </button>
                </td>
                <td>${m.account}</td>
                <td><button type="button" onclick="del(this,'${m.id}')" class="glyphicon glyphicon-trash"></button>
                </td>
            </tr>
        </c:forEach>

        </tbody>
    </table>
</div>

<%@include file="bottom.jsp"%>



<script>
    $(function () {
        $("[data-toggle='popover']").popover();
    });


    function del(obj,id) {
        if(confirm("确定删除该消息")) {
        let tbody = document.getElementById("tb");
        $.ajax({
            type:'post',
            url:'/taofang/message/deltenant.action',
            data:{'id':id},
            success:function(data){
                if(data.code==200){
                    //js能力 从tbody中删除当前删除的tr
                    let tr = obj.parentElement.parentElement;
                    tbody.removeChild(tr);
                }else{
                    alert("删除失败!");
                }
            }
        })
        }else{

        }

    }

</script>
</body>
</html>
